﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace PocketPatients
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            //string[] names = PluginBroker.List();
            //foreach (string name in names)
        	//{
            //    PluginBroker.Load(name).Load();
	        //}
            PersistentObjects.Persistent.ConnectionString = "Data Source = " + SharedData.GetApplicationDirectory() + "\\Patients.sqlite; UseUTF16Encoding = True";
            PersistentObjects.DDL<Patient>.CreateTable();
            PersistentObjects.DDL<Visit>.CreateTable();

            //SharedData.Patients.DataSource = new PersistentObjects.PersistentList<Patient>();
            PersistentObjects.PersistentList<Patient> patients = new PersistentObjects.PersistentList<Patient>(false);
            patients.Select.Add(new PersistentObjects.SelectWhereClause("LastName", "Richana"));
            patients.Update();
            SharedData.Patients.DataSource = patients;

            Application.Run(new PocketPatientsForm());


            //Visit visit = new Visit();
            //visit.Patient = ((PersistentObjects.PersistentList<Patient>)SharedData.Patients.DataSource)[0];
            foreach (Patient patient in (PersistentObjects.PersistentList<Patient>)SharedData.Patients.DataSource)
                patient.Persist();
            //visit.Persist();
        }
    }
}